<?php 
session_start(); 
require_once('include/connect.inc.php'); 
if($_SESSION['sess_id'] <> session_id()){
?>
 <SCRIPT LANGUAGE="JavaScript">
			alert("กรุณาเข้าสู่ระบบให้ถูกต้องตามขั้นตอน...!");
			location="login.php";
</script>
<?php }?>
<?php
$id=$_SESSION['id'];
if($_REQUEST['admin_id'] != "") //ถ้า ค่า admin_id ไม่เท่ากับค่าว่างเปล่า
{
$del_id = $_REQUEST['admin_id'];
$sql_del = "delete from tb_admin where r_admin_id = '$admin_id';";
mysql_query($sql_del) or die(mysql_error());
$admin_id = $rs['admin_id'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Model Test Program</title>
<link rel="stylesheet" type="text/css" href="template/template_style_wood.css">
</head>

<body>
<div id="menu"><div><img src="../images/icon-m.png" /></div>
<div id="menulinks">
		<a class="active" href="person.php">จัดการบุคลากร</a>
		<a  href="problem/admin_resive.php">ตรวจสอบความคิดเห็น</a>
        <a  href="new/manage_news.php">ประกาศข่าวสาร</a>
        <a href="logout.php">ออกจากระบบ</a>
		</div></div>
        
      <div id="p3">    
<div id="header"></div>
<div id="page"><div id="p1">คุณ<?php echo"$admin_name";?><hr />
	<form name="form1" id="form1" method="post" action="person_show_ad.php">
    <table  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left"> จัดการข้อมูลผู้จัดการระบบ</th>
        <th align="right"><a href="person_insert_ad.php"><img src="images/add.png" border="0" /></a></th>
      </tr>
    </table>
	 <table border="0"  id="table"  summary="2007 Major IT Companies Profit">
      <tr>
        <th align="center">ลำดับ</th>
        <th align="center">รหัสประจำตัว</th>
        <th align="center">รหัสผ่าน</th>  
        <th align="center">ชื่อ - สกุล</th>
        <th align="center">e-mail</th>
        <th align="center">เบอร์โทรศัพท์</th>
        <th align="center">ลบ</th>
        <th align="center">แก้ไข</th>
      </tr>
          <?php
		$query = query("SELECT * FROM tb_admin ORDER BY r_admin_id asc");
		$count=1;
		while ($rs = fetch_array($query)) {
		    $r_admin_ids = $rs['r_admin_id'];
			$admin_password = $rs['admin_password'];
			$admin_fname = $rs['admin_fname'];
			$admin_lname = $rs['admin_lname'];
			$admin_email = $rs['admin_email'];
			$admin_phone = $rs['admin_phone'];
		?>
      <tr>
        <td align="center"><?php echo $count;echo ".";?></td>
        <td ><?php echo $r_admin_ids;?></td>
      <td ><?php echo $admin_password;?></td>
      <td><? echo $admin_fname; echo " "; echo $admin_lname;  ?></a></td>
      <td ><?php echo $admin_email;?></td>
      <td ><?php echo $admin_phone;?></td>
        <td>  <? if ($id==$r_admin_ids) { ?>
      <? echo " "; ?>
        <? } else { ?>
	        <script language="JavaScript">
		function Conf<?=$rs["r_admin_id"]; ?>(object) {
		if (confirm("ยืนยันการลบข้อมูล") ==true) {
		return true;
		}
		return false;
		}
          </script>
        <a href="person_show_ad.php?admin_id=<?=$rs["r_admin_id"];?>"
      onclick="return Conf<?=$rs["r_admin_id"]; ?>(this)"> <img src="images/delete1.png" border="0" /></a>
      <?php } ?>
      </td>
        <td align="center"><? if ($id==$r_admin_ids) { ?>
      <a href="person_edit_ad.php?admin_id=<?=$rs["r_admin_id"];?>"><img src="images/edit.png" border="0" /></a>
        <? } else { ?>  
        <? echo " "; }?>
        </td>
      </tr>
       <?php $count++; } ?>
    </table><br /><br /><br />
  </form>
    </div>
    </div>
<div id="footer"></div>
</div>
</body>
</html>